package com.apes.enquiry.voluntaryOffers.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.apes.framework.query.ApesDao;
import org.springframework.stereotype.Component;

@Component
public class MatchingRuleDao extends ApesDao {

    public JSONArray findAatchingRule(String sql) {
        return toJSONArray(find(sql));

    }

    public JSONArray findByReplaceParts(JSONObject param) {
        String sql = "SELECT A.BRAND, A.PN\n" +
                "  FROM SP_MAS_REPLACEMENT_PRODUCT A,\n" +
                "       (SELECT REPLACEMENT FROM SP_MAS_REPLACEMENT_PRODUCT WHERE PN =:OE AND BRAND=:QCPPMC) B\n" +
                " WHERE A.REPLACEMENT = B.REPLACEMENT";
        return toJSONArray(find(sql, param));
    }

    public JSONArray findByBrandPiece(JSONObject param) {
        String sql = "SELECT BRAND,BRAND_ID FROM SP_MAS_BRAND_UPLOADING WHERE AUTOMOBILE=:BRAND AND PN =:PN";
        return toJSONArray(find(sql, param));
    }
}
